def idStr():
    name = "zhangsan"
    print(name)
    print(id(name))
    name2 = name.upper()
    print(name)
    print(id(name))
    print(name2)
    print(id(name2))


def splitStr():
    name = "大海"
    print(name * 10)
    print('---------------')
    msg = 'abcdefghijklmnopqrstxyz'
    # 索引从0开始，现实中书本的页码从1开始
    # 取出第一个英文字符
    print(msg[0])
    print(msg[1])
    print(msg[-1])
    print('---------------')
    print(msg[0:5])  # abcde
    print(msg[0:5:2])  # ace
    print('---------------')
    print(msg[::])  # abcdefghijklmnopqrstxyz
    print(msg[0::])  # abcdefghijklmnopqrstxyz
    print(msg[0::2])  # acegikmoqsxz
    print('------步长小于0表示从后向前，从某索引到某索引（不包含）-------')
    print(msg[::-1])  # zyxtsrqponmlkjihgfedcba
    print(msg[10:3:-1])  # kjihgfe
    print(msg[10:5:-2])  # kig


def formatStr():
    # format
    print('my name is {}'.format('dahai'))
    print('my name is {1} my age is {0}'.format(18, 'dahai'))
    print('my name is {name} my age is {age}'.format(age=18, name='dahai'))
    name = 'zhangsan'
    age = 18
    print('my name is %s my age is %d' % (name, age))
    print(f'my name is {name} my age is {age}')


# formatStr()


def joinStr():
    # join
    str1 = '真正的勇士'
    str2 = '敢于直面惨淡的人生'
    str3 = '敢于正视淋漓的鲜血'
    print(str3 + str2 + str1)
    # 可以把列表里面的元素组合成字符串
    print(''.join([str1, str2, str3]))
    print(','.join([str1, str2, str3]))
    print('哇塞'.join([str1, str2, str3]))
    print('  '.join([str1, str2, str3]))


# joinStr()


def deleteStr():
    name = "zhangsan"
    print(name)
    del name
    print(name)


# deleteStr()


def findStr():
    msga = 'hello dahai is dsb dahai'
    print(msga.find('dahai'))
    # 没找到会返回-1
    print(msga.find('ddddd'))
    # 没找到会报错
    print(msga.index('dahai'))
    # print(msga.index('ddddd'))
    # 统计一个子字符串在大字符串中出现的次数 count
    print(msga.count('dahai'))


# findStr()


def doSomeCheck():
    num = '1818'
    num1 = '18aaa18'
    aaaa = 'aaa'
    print(num, " isdigit ", num.isdigit())
    print(num1, " isdigit ", num1.isdigit())
    # print(type(input('>>>')))
    # 判断每个元素是不是都是字母 isalpha
    print(aaaa, " isalpha ", aaaa.isalpha())
    print(num, " isalpha ", num.isalpha())
    print(num1, " isalpha ", num1.isalpha())
    # 比较开头的元素是否相同 startswith
    # 比较结尾的元素是否相同 endswith
    # 返回布尔类型
    mm = 'dahai xialuo'
    print(mm, " startswith dahai: ", mm.startswith('dahai'))
    print(mm, "  endswith  uo: ", mm.endswith('uo'))
    # 判断字符串中的值是否全是小写的 islower
    # 判断字符串中的值是否全是大写的 isupper
    letter2 = 'ABC'
    letter3 = 'abc'
    letter4 = 'aAbc'
    print(letter2, '  isupper  ', letter2.isupper())
    print(letter3, '  isupper  ', letter3.isupper())
    print(letter4, '  isupper  ', letter4.isupper())
    print(letter2, '  islower  ', letter2.islower())
    print(letter3, '  islower  ', letter3.islower())
    print(letter4, '  islower  ', letter4.islower())


# doSomeCheck()

# str = '123'+"_"+"abc"
# print(str)


print('dahai'.center(11, '*'))
print('dahai'.ljust(11, '*'))
print('dahai'.rjust(11, '*'))
